﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <xsl:param name="columnNames"/>
    <html>
      <body>
        <h2>
          <xsl:value-of select="statistics/year" />年<xsl:value-of select="statistics/title" />统计结果: [<xsl:value-of select="statistics/owner" />]
        </h2>
        <h3>
          <xsl:value-of select="statistics/role" /> 共 <xsl:value-of select="statistics/total" /> 份问卷
        </h3>
        <table border="1">
          <tr bgcolor="#9acd32">
            <th align="center" width="100"></th>
            <xsl:for-each select="statistics/columns">
              <xsl:for-each select="*">
                <th align="center" width="100">
                  选<xsl:value-of select="name()" />的
                </th>
              </xsl:for-each>
            </xsl:for-each>
          </tr>
          <xsl:variable name="total" select="statistics/total" />
          <xsl:for-each select="statistics/sQuestion">
            <tr>
              <th align="left">
                第<xsl:value-of select="qIndex" />题
                <xsl:choose>
                  <xsl:when test="type = 'MultipleChoices'">
                    (多选题)
                  </xsl:when>
                  <xsl:otherwise>
                  </xsl:otherwise>
                </xsl:choose>
              </th>
              <xsl:for-each select="answer">
                <xsl:for-each select="*">
                  <th align="center" width="100">
                    <xsl:choose>
                      <xsl:when test=". > 0">
                        <xsl:value-of select="." /> (<xsl:value-of select="format-number(. div $total, '##.#%')" />)
                      </xsl:when>
                      <xsl:otherwise>
                        <xsl:value-of select="." />
                      </xsl:otherwise>
                    </xsl:choose>
                  </th>
                </xsl:for-each>
              </xsl:for-each>
            </tr>
          </xsl:for-each>
        </table>
        <br></br>
        <br></br>
        
        <xsl:choose>
          <xsl:when test="statistics/index != 2">
            <xsl:for-each select="statistics/columns">
              <xsl:for-each select="*">
                <p>
                  <xsl:value-of select="name()" />. <xsl:value-of select="." />
                </p>
              </xsl:for-each>
            </xsl:for-each>
          </xsl:when>
          <xsl:otherwise>

          </xsl:otherwise>
        </xsl:choose>

      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>